{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <contact@prestashop.com>
*  @copyright  2007-2012 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}

<script type="text/javascript">
   
    $(document).ready(function () {

    var currentDate = new Date();
    var day = currentDate.getDay();

    var currentHour = currentDate.getHours();
    var htmlDelivery = "Your earliest delivery time:" + currentDate.getDate() + "-" + (currentDate.getMonth() + 1 ) + "-" + currentDate.getFullYear() ;
    if (day > 0 && day < 6) {
    if (currentHour < 14) {
    htmlDelivery += " 7:30pm – 10pm ";
}
else if (currentHour >= 14 && currentHour <= 17) {
var nextDate = new Date();
nextDate.setDate(nextDate.getDate() + 1);
htmlDelivery = "Your earliest delivery time: 9am, " + (nextDate.getDate()) + "-" + ( nextDate.getMonth() + 1) + "-" + nextDate.getFullYear() ;

}
else {
var nextDate = new Date();
nextDate.setDate(nextDate.getDate() + 1);
htmlDelivery = "Your earliest delivery time:After 2pm, " + (nextDate.getDate()) + "-" + (nextDate.getMonth() + 1) + "-" + nextDate.getFullYear() ;

}
document.getElementById('deliveryHtml').innerHTML = htmlDelivery;
$("#monday").show();
$("#saturday").hide();
$("#sunday").hide();
}
else if (day == 0) {
var nextDate = new Date();
nextDate.setDate(nextDate.getDate() + 1);
htmlDelivery = "Your earliest delivery time:After 2pm, " + (nextDate.getDate()) + "-" + (nextDate.getMonth() + 1) + "-" + nextDate.getFullYear() ;
document.getElementById('deliveryHtml').innerHTML = htmlDelivery;
$("#monday").hide();
$("#saturday").hide();
$("#sunday").show();
}
else {
if (currentHour < 14) {
htmlDelivery = "Your earliest delivery time:" + currentDate.getDate() + "-" + (currentDate.getMonth() + 1) + "-" + currentDate.getFullYear() ;
htmlDelivery += " 7:30pm – 10pm ";
}

else {
var nextDate = new Date();
nextDate.setDate(nextDate.getDate() + 1);
htmlDelivery = "Your earliest delivery time:After 2pm, " + (nextDate.getDate()) + "-" + (nextDate.getMonth() + 1) + "-" + nextDate.getFullYear() ;

}
document.getElementById('deliveryHtml').innerHTML = htmlDelivery;

$("#monday").hide();
$("#saturday").show();
$("#sunday").hide();

}

$('#datepicker').datepicker({
changeMonth:true,
dateFormat:'dd-mm-yy',
changeYear:true,

minDate:0,
onSelect:function (dateText, inst) {
var startDate = compareDate(dateText);
var selDay = startDate.getDay();
if (selDay > 0 && selDay < 6) {
$("#monday").show();
$("#saturday").hide();
$("#sunday").hide();
}
else if (selDay == 0) {
$("#monday").hide();
$("#saturday").hide();
$("#sunday").show();
}
else {
$("#monday").hide();
$("#saturday").show();
$("#sunday").hide();

}
var radios = document.getElementsByTagName('input');

for (var i = 0; i < radios.length; i++) {
if (radios[i].type === 'radio' && radios[i].checked) {
// get value, set checked flag or do whatever you need to

radios[i].value = null;
}
}
}

}).datepicker("setDate", "0");

});

function compareDate(str1) {
// str1 format should be dd/mm/yyyy. Separator can be anything e.g. / or -. It wont effect
var dt1 =str1.substring(0, 2);
var mon1 = str1.substring(3, 5);
var yr1 = str1.substring(6, 10);
var txtDate=yr1+"/"+mon1+"/"+dt1+" 00:00:00 AM";
alert(txtDate);
var date1 = new Date(txtDate);
return date1;

}
function updateDelivery(value) {
var htmlDelivery;
var dateSelected = document.getElementById("datepicker").value;
var currentDate = compareDate(dateSelected);

if (value == 1) {
htmlDelivery = "Your earliest delivery time:" + currentDate.getDate() + "-" + (currentDate.getMonth() + 1 ) + "-" + currentDate.getFullYear() ;
htmlDelivery += " 7:30pm – 10pm ";
document.getElementById('deliveryHtml').innerHTML = htmlDelivery;
}
else if (value == 2) {
var nextDate = compareDate(dateSelected);
nextDate.setDate(nextDate.getDate() + 1);
htmlDelivery = "Your earliest delivery time: 9:00 am, " + (nextDate.getDate()) + "-" + ( nextDate.getMonth() + 1) + "-" + nextDate.getFullYear();
document.getElementById('deliveryHtml').innerHTML = htmlDelivery;

}
else if (value == 3) {
var nextDate = compareDate(dateSelected);
nextDate.setDate(nextDate.getDate() + 1);
htmlDelivery = "Your earliest delivery time:After 2:00 pm, " + (nextDate.getDate()) + "-" + (nextDate.getMonth() + 1) + "-" + nextDate.getFullYear() ;
document.getElementById('deliveryHtml').innerHTML = htmlDelivery;

}
else if (value == 4) {
htmlDelivery = "Your earliest delivery time:" + currentDate.getDate() + "-" + (currentDate.getMonth() + 1) + "-" + currentDate.getFullYear() ;
htmlDelivery += " 7:30pm – 10pm ";
document.getElementById('deliveryHtml').innerHTML = htmlDelivery;

}
else if (value == 5) {
var nextDate = compareDate(dateSelected);
nextDate.setDate(nextDate.getDate() + 1);
htmlDelivery = "Your earliest delivery time:After 2:00pm, " + (nextDate.getDate()) + "-" + (nextDate.getMonth() + 1) + "-" + nextDate.getFullYear();
document.getElementById('deliveryHtml').innerHTML = htmlDelivery;
}
else {
var nextDate = compareDate(dateSelected);
nextDate.setDate(nextDate.getDate() + 1);
htmlDelivery = "Your earliest delivery time:After 2:00pm, " + (nextDate.getDate()) + "-" + (nextDate.getMonth() + 1) + "-" + nextDate.getFullYear() ;
document.getElementById('deliveryHtml').innerHTML = htmlDelivery;

}

}
function checkRadio() {
var radios = document.getElementsByTagName('input');
var value;
var dateSelected = document.getElementById("datepicker").value;
if (compareDate(dateSelected).getDay() == 0) {
var nextDate = compareDate(dateSelected);
nextDate.setDate(nextDate.getDate() + 1);

deliveryDateTime = nextDate.getFullYear();
deliveryDateTime += '-';
deliveryDateTime += ( nextDate.getMonth() + 1) > 9 ? ( nextDate.getMonth() + 1) : ('0' + ( nextDate.getMonth() + 1));
deliveryDateTime += '-';

deliveryDateTime += nextDate.getDate() > 9 ? nextDate.getDate() : ('0' + nextDate.getDate());
deliveryDateTime += ' 14:00:00';
return deliveryDateTime;
}
for (var i = 0; i < radios.length; i++) {
if (radios[i].type === 'radio' && radios[i].checked) {
// get value, set checked flag or do whatever you need to
value = radios[i].value;
}
}
if (!value) {
return false;
}
var deliveryDateTime;

if (value == 1) {
deliveryDateTime = dateSelected + " 19:30:00 - 22:00:00";
}
else if (value == 2) {
var nextDate = compareDate(dateSelected);
nextDate.setDate(nextDate.getDate() + 1);

deliveryDateTime = nextDate.getFullYear();
deliveryDateTime += '-';
deliveryDateTime += ( nextDate.getMonth() + 1) > 9 ? ( nextDate.getMonth() + 1) : ('0' + ( nextDate.getMonth() + 1));
deliveryDateTime += '-';

deliveryDateTime += nextDate.getDate() > 9 ? nextDate.getDate() : ('0' + nextDate.getDate());
deliveryDateTime += ' 09:00:00';


}
else if (value == 3) {
var nextDate = compareDate(dateSelected);
nextDate.setDate(nextDate.getDate() + 1);

deliveryDateTime = nextDate.getFullYear();
deliveryDateTime += '-';
deliveryDateTime += ( nextDate.getMonth() + 1) > 9 ? ( nextDate.getMonth() + 1) : ('0' + ( nextDate.getMonth() + 1));
deliveryDateTime += '-';

deliveryDateTime += nextDate.getDate() > 9 ? nextDate.getDate() : ('0' + nextDate.getDate());
deliveryDateTime += ' 14:00:00';

}
else if (value == 4) {
deliveryDateTime = dateSelected + " 19:30:00 - 22:00: 00";
}
else if (value == 5) {
var nextDate = compareDate(dateSelected);
nextDate.setDate(nextDate.getDate() + 1);

deliveryDateTime = nextDate.getFullYear();
deliveryDateTime += '-';
deliveryDateTime += ( nextDate.getMonth() + 1) > 9 ? ( nextDate.getMonth() + 1) : ('0' + ( nextDate.getMonth() + 1));
deliveryDateTime += '-';

deliveryDateTime += nextDate.getDate() > 9 ? nextDate.getDate() : ('0' + nextDate.getDate());
deliveryDateTime += ' 14:00:00';

}

else {
var nextDate = compareDate(dateSelected);
nextDate.setDate(nextDate.getDate() + 1);

deliveryDateTime = nextDate.getFullYear();
deliveryDateTime += '-';
deliveryDateTime += ( nextDate.getMonth() + 1) > 9 ? ( nextDate.getMonth() + 1) : ('0' + ( nextDate.getMonth() + 1));
deliveryDateTime += '-';

deliveryDateTime += nextDate.getDate() > 9 ? nextDate.getDate() : ('0' + nextDate.getDate());
deliveryDateTime += ' 14:00:00';

}
return deliveryDateTime;

}
function validDelivery() {

var deliveryTime = checkRadio();
if (!deliveryTime) {
alert("You must select order time");
return false;
}
else {
document.getElementById("datepicker").value = deliveryTime;
}
var txtFrom='';
var txtTo='';
var txtMessage='';
var txtMessage='';
txtFrom='From: '+document.getElementById("txtFrom1").value+'\nFrom: '+document.getElementById("txtFrom2").value+'\nFrom: '+document.getElementById("txtFrom3").value+'\n';
txtTo='To: '+document.getElementById("txtTo1").value+'\nTo: '+document.getElementById("txtTo2").value+'\nTo: '+document.getElementById("txtTo3").value+'\n';
txtMessage='\nMessage 1:'+document.getElementById("txtMessage1").value+'\nMessage 2: '+document.getElementById("txtMessage2").value+'\nMessage 3:'+document.getElementById("txtMessage3").value+'\n';
document.getElementById("txtFrom").value = txtFrom;
document.getElementById("txtTo").value = txtTo;
document.getElementById("txtMessage").value = txtMessage;
$("#address2").val($("#building-address").val()+"-"+$("#street-address").val())
$("#address1").val($("#block-address").val()+"-"+$("#unit-address").val())
return true;
}
// <![CDATA[
idSelectedCountry = {if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{else}{if isset($address['id_state'])}{$address['id_state']|intval}{else}false{/if}{/if};
countries = new Array();
countriesNeedIDNumber = new Array();
countriesNeedZipCode = new Array();
    {foreach from=$countries item='country'}
        {if isset($country.states) && $country.contains_states}
countries[{$country.id_country|intval}] = new Array();
            {foreach from=$country.states item='state' name='states'}
countries[{$country.id_country|intval}].push({ldelim}'id' : '{$state.id_state}', 'name' : '{$state.name|addslashes}'{rdelim});
            {/foreach}
        {/if}
        {if $country.need_identification_number}
countriesNeedIDNumber.push({$country.id_country|intval});
        {/if}
        {if isset($country.need_zip_code)}
countriesNeedZipCode[{$country.id_country|intval}] = {$country.need_zip_code};
        {/if}
    {/foreach}
$(function(){ldelim}
$('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{else}{if isset($address['id_state'])}{$address['id_state']|intval}{/if}{/if}]').attr('selected', true);
    {rdelim});
    {if $vat_management}
        {literal}
        $(document).ready(function() {
                $('#company').blur(function(){
                        vat_number();
                });
                vat_number();
                function vat_number()
                {
                        if ($('#company').val() != '')
                                $('#vat_number').show();
                        else
                                $('#vat_number').hide();
                }
        });
        {/literal}
    {/if}
//]]>
</script>


<h1 id="cart_title">{l s='Delivery info'}</h1>

<h3>
    {*{if isset($id_address) && (isset($smarty.post.alias) || isset($address['alias']))}
    {l s='Modify address'} 
    {if isset($smarty.post.alias)}
    "{$smarty.post.alias}"
    {else}
    {if isset($address['alias'])}"{$address['alias']}"{/if}
    {/if}
    {else}
    {l s='To add a new address, please fill out the form below.'}
    {/if}
    *}
</h3>
{assign var='current_step' value='delivery'}
{include file="$tpl_dir./order-steps.tpl"}
{include file="$tpl_dir./errors.tpl"}

<form action="{$link->getPageLink('order&step=2', true)}" method="post" class="std" id="add_adress"  onsubmit="return validDelivery()">
    <div style="width: 960px; float: left; background: none repeat scroll 0% 0% white; padding: 10px;"class="container-deliveryaddress">
        <p style="font-weight: bold;font-size: 22px">{l s='Billing address'}</p><br/>
        <p class="required"><sup>*</sup> {l s='Required field'}</p>
        <table style="width: 100%">
            <tr>
                <td>
                    Title *
                </td>
                <td>
                    <select>
                        <option>Mr</option>
                    </select>
                </td>
                <td>
                    City *
                </td>
                <td>
                    <input name="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{else}{if isset($address['city'])}{$address['city']}{/if}{/if}">
                </td>
            </tr>
            <tr>
                <td>
                    Given Name *
                </td>
                <td>
                    <input name="firstname" value="{if isset($smarty.post.firstname)}{$smarty.post.firstname}{else}{if isset($address['firstname'])}{$address['firstname']}{/if}{/if}">
                </td>
                <td>
                    State *
                </td>
                <td>
                    <select name="id_state" id="id_state">
                        <option value="">-</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    Surname *
                </td>
                <td>
                    <input name="lastname" value="{if isset($smarty.post.lastname)}{$smarty.post.lastname}{else}{if isset($address['lastname'])}{$address['lastname']}{/if}{/if}">
                </td>
                <td>
                    Country *
                </td>
                <td>
                    <select id="id_country" name="id_country">{$countries_list}</select>
                </td>
            </tr>
            <tr>
                <td>
                    Company *
                </td>
                <td>
                    <input name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{else}{if isset($address['company'])}{$address['company']}{/if}{/if}">
                </td>
                <td>
                    Postal Code *
                </td>
                <td>
                    <input  id="postcode" type="text" onkeyup="$('#postcode').val($('#postcode').val().toUpperCase());" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{else}{if isset($address['postcode'])}{$address['postcode']}{/if}{/if}" name="postcode">
                </td>
            </tr>
            <tr>
                <td>
                    Block 
                </td>
                <td>
                    <input name="block" id="block-address"value="{if isset($smarty.post.block)}{$smarty.post.block}{else}{if isset($address['block'])}{$address['block']}{/if}{/if}">
                    <span>Unit #</span>
                    <input name="unit" id="unit-address"value="{if isset($smarty.post.unit)}{$smarty.post.unit}{else}{if isset($address['unit'])}{$address['unit']}{/if}{/if}">
                </td>
                <td>

                </td>
                <td>

                </td>
            </tr>
            <tr>
                <td>
                    Building * 
                </td>
                <td>
                    <input name="building" id="building-address"value="{if isset($smarty.post.building)}{$smarty.post.building}{else}{if isset($address['building'])}{$address['building']}{/if}{/if}">
                </td>
                <td>
                    Mobile Number *
                </td>
                <td>
                    <input name="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{else}{if isset($address['phone_mobile'])}{$address['phone_mobile']}{/if}{/if}">
                </td>
            </tr>
            <tr>
                <td>
                    Street * 
                </td>
                <td>
                    <input name="street" id="street-address"value="{if isset($smarty.post.street)}{$smarty.post.street}{else}{if isset($address['street'])}{$address['street']}{/if}{/if}">
                </td>
                <td>
                    Work Number 
                </td>
                <td>
                    <input name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{else}{if isset($address['phone'])}{$address['phone']}{/if}{/if}">
                </td>
            </tr>
            <tr>
                <td>
                    Email * 
                </td>
                <td>
                    <input name="guest_email" value="{if isset($smarty.post.guest_email)}{$smarty.post.guest_email}{/if}">
                </td>
                <td>

                </td>
                <td>

                </td>
            </tr>
        </table>
    </div>
    <div style="margin-top: 10px;width: 960px; float: left; background: none repeat scroll 0% 0% white; padding: 10px;"class="container-deliveryaddress">
        <p style="font-weight: bold;font-size: 22px">{l s='Delivery Option'}</p><br/>
        {l s=' Please choose delivery date time:'}
        <div id="showDelivery">
            <p id="deliveryHtml"></p>
        </div>
        <table style="width: 50%">
            <tr>
                <td>
                    Date
                </td>
                <td>
                    <input type="text" id="datepicker" name="datepicker"/>
                </td>
            </tr>
            <tr>
                <td>
                    Time
                </td>
                <td>
                    <div id="monday">
                        <span><input type="radio" value="1" name="ordertime" onclick="updateDelivery(this.value)">Before 2pm</span>
                        <br/>
                        <span><input type="radio" value="2" name="ordertime" onclick="updateDelivery(this.value)">2pm to 5pm</span>
                        <br/>
                        <span><input type="radio" value="3" name="ordertime" onclick="updateDelivery(this.value)">After 5pm</span>
                    </div>
                    <div id="saturday">
                        <span><input type="radio" value="4" name="ordertime" onclick="updateDelivery(this.value)">Before 2pm</span>
                        <br/>
                        <span><input type="radio" value="5" name="ordertime" onclick="updateDelivery(this.value)">After 2pm</span>

                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div style="margin-top: 10px;width: 960px; float: left; background: none repeat scroll 0% 0% white; padding: 10px;"class="container-deliveryaddress">
        <p style="font-weight: bold;font-size: 22px">{l s='Message to recipient'}</p><br/>
        <table style="width: 50%;float: left">
            <tr>
                <td>
                    To
                </td>
                <td>
                    <input type="text" id="txtTo1" name="txtTo1"/>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input type="text" id="txtTo2" name="txtTo2"/>
                <td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input type="text" id="txtTo3" name="txtTo3"/>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input type="hidden" id="txtTo" name="txtTo"/>
                </td>
            </tr>
            <tr>
                <td>
                    From
                </td>
                <td>
                    <input type="text" id="txtFrom1" name="txtFrom1"/>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input type="text" id="txtFrom2" name="txtFrom2"/>
                <td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input type="text" id="txtFrom3" name="txtFrom3"/>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input type="hidden" id="txtFrom" name="txtFrom"/>
                </td>
            </tr>
        </table>
        <table style="width: 50%;float: left">
            <tr style="display: none">
                <td>
                    Greeting Type
                </td>
                <td>
                    <select id="GreetingType">
                        <option value="1">Type 1</option>
                        <option value="2">Type 2</option>
                        <option value="3">Type 3</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    Message
                </td>
                <td>
                    <input type="text" id="txtMessage1" name="txtMessage1"/>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input type="text" id="txtMessage2" name="txtMessage2"/>
                <td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input type="text" id="txtMessage3" name="txtMessage2"/>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input type="hidden" id="txtMessage" name="txtMessage"/>
                </td>
            </tr>
        </table>
    </div>
    <fieldset style="display: none">
        <h3>{if isset($id_address)}{l s='Your address'}{else}{l s='New address'}{/if}</h3>

        <p class="required text dni">
            <label for="dni">{l s='Identification number'}</label>
            <input type="text" class="text" name="dni" id="dni"
                   value="{if isset($smarty.post.dni)}{$smarty.post.dni}{else}{if isset($address['dni'])}{$address['dni']}{/if}{/if}"/>
            <span class="form_info">{l s='DNI / NIF / NIE'}</span>
            <sup>*</sup>
        </p>
        {assign var="stateExist" value="false"}
        {foreach from=$ordered_adr_fields item=field_name}
            {if $field_name eq 'company'}
                <p class="text">
                    <input type="hidden" name="token" value="{$token}"/>
                    {* <label for="company">{l s='Company'}</label>
                    <input type="text" id="company" name="company"
                    value="{if isset($smarty.post.company)}{$smarty.post.company}{else}{if isset($address['company'])}{$address['company']}{/if}{/if}"/>
                    *}
                </p>
                {if $vat_display == 2}
                    <div id="vat_area">
                    {elseif $vat_display == 1}
                        <div id="vat_area" style="display: none;">
                        {else}
                            <div style="display: none;">
                            {/if}
                            <div id="vat_number">
                                <p class="text">
                                    <label for="vat_number">{l s='VAT number'}</label>
                                    <input type="text" class="text" name="vat_number"
                                           value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number}{else}{if isset($address['vat_number'])}{$address['vat_number']}{/if}{/if}"/>
                                </p>
                            </div>
                        </div>
                    {/if}
                    {if $field_name eq 'firstname'}
                        <p class="required text">
                            {* <label for="firstname">{l s='First name'} <sup></sup></label>
                            <input type="text" name="firstname" id="firstname"
                            value="{if isset($smarty.post.firstname)}{$smarty.post.firstname}{else}{if isset($address['firstname'])}{$address['firstname']}{/if}{/if}"/>
                            *}
                        </p>
                    {/if}
                    {if $field_name eq 'lastname'}
                        <p class="required text">
                            {* <label for="lastname">{l s='Last name'} <sup></sup></label>
                            <input type="text" id="lastname" name="lastname"
                            value="{if isset($smarty.post.lastname)}{$smarty.post.lastname}{else}{if isset($address['lastname'])}{$address['lastname']}{/if}{/if}"/>
                            *}
                        </p>
                    {/if}
                    {if $field_name eq 'address1'}
                        <p class="required text">

                            <input type="hidden" id="address1" name="address1"
                                   value="{if isset($smarty.post.address1)}{$smarty.post.address1}{else}{if isset($address['address1'])}{$address['address1']}{/if}{/if}"/>
                        </p>
                    {/if}
                    {if $field_name eq 'address2'}
                        <p class="required text">

                            <input type="hidden" id="address2" name="address2"
                                   value="{if isset($smarty.post.address2)}{$smarty.post.address2}{else}{if isset($address['address1'])}{$address['address2']}{/if}{/if}"/>
                        </p>
                    {/if}
                    {if $field_name eq 'postcode'}
                        <p class="required postcode text">
                            {*<label for="postcode">{l s='Zip / Postal Code'} <sup></sup></label>
                            <input type="text" id="postcode" name="postcode"
                            value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{else}{if isset($address['postcode'])}{$address['postcode']}{/if}{/if}"
                            onkeyup="$('#postcode').val($('#postcode').val().toUpperCase());"/>
                            *}
                        </p>
                    {/if}
                    {if $field_name eq 'city'}
                        <p class="required text">
                            {*<label for="city">{l s='City'} <sup></sup></label>
                            <input type="text" name="city" id="city"
                            value="{if isset($smarty.post.city)}{$smarty.post.city}{else}{if isset($address['city'])}{$address['city']}{/if}{/if}"
                            maxlength="64"/>
                            *}
                        </p>
                        {*
                        if customer hasn't update his layout address, country has to be verified
                        but it's deprecated
                        *}
                    {/if}
                    {if $field_name eq 'Country:name' || $field_name eq 'country'}
                        <p class="required select">
                            {* <label for="id_country">{l s='Country'} <sup></sup></label>
                            <select id="id_country" name="id_country">{$countries_list}</select>
                            *}
                        </p>
                        {if $vatnumber_ajax_call}
                            <script type="text/javascript">
var ajaxurl = '{$ajaxurl}';
                                {literal}
                        $(document).ready(function () {
                            $('#id_country').change(function () {
                                $.ajax({
                                    type:"GET",
                                    url:ajaxurl + "vatnumber/ajax.php?id_country=" + $('#id_country').val(),
                                    success:function (isApplicable) {
                                        if (isApplicable == "1") {
                                            $('#vat_area').show();
                                            $('#vat_number').show();
                                        }
                                        else {
                                            $('#vat_area').hide();
                                        }
                                    }
                                });
                            });
                        });
                                {/literal}
                            </script>
                        {/if}
                    {/if}
                    {if $field_name eq 'State:name'}
                        {assign var="stateExist" value="true"}
                        <p class="required id_state select">
                            {*<label for="id_state">{l s='State'} <sup></sup></label>
                            <select name="id_state" id="id_state">
                            <option value="">-</option>
                            </select>
                            *}
                        </p>
                    {/if}
                {/foreach}
                {if $stateExist eq "false"}
                    <p class="required id_state select">
                        {* <label for="id_state">{l s='State'} <sup></sup></label>
                        <select name="id_state" id="id_state">
                        <option value="">-</option>
                        </select>
                        *}
                    </p>
                {/if}
                <p class="textarea">
                    <label for="other">{l s='Additional information'}</label>
                    <textarea id="other" name="other" cols="26"
                              rows="3">{if isset($smarty.post.other)}{$smarty.post.other}{else}{if isset($address['other'])}{$address['other']}{/if}{/if}</textarea>
                </p>

                <p class="required text" id="adress_alias">
                    {assign var=unique_id value=0|mt_rand:10000000}
                    <input type="text" id="alias" name="alias"
                           value="Delivery address{$unique_id}"/>
                </p>
                </fieldset>
                <p class="submit2" style="float: left;width: 100%">
                {if isset($id_address)}<input type="hidden" name="id_address" value="{$id_address|intval}" />{/if}
            {if isset($back)}<input type="hidden" name="back" value="{$back}" />{/if}
        {if isset($mod)}<input type="hidden" name="mod" value="{$mod}" />{/if}
    {if isset($select_address)}<input type="hidden" name="select_address" value="{$select_address|intval}" />{/if}
    <input type="submit" name="submitAddress" id="submitAddress" value="{l s='Next'}" class="button" />
</p>
</form>
